home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: esds01.es.dupont.com!news
- From: Malcolm Smart <MALCOLM.SMART@CONOCO.DUPONT.COM>
- Subject: ***NASA USE C++ TO GO MARTIAN ***
- Content-Type: text/plain; charset=us-ascii
- Message-ID: <1996Feb15.100604.29166@es.dupont.com>
- Sender: news@es.dupont.com (USENET News System)
- Nntp-Posting-Host: slai99.wrk.dupont.com
- Content-Transfer-Encoding: 7bit
- Organization: Conoco/DuPont
- References: <1996Feb13.095916.26002@es.dupont.com>
- Mime-Version: 1.0
- Date: Thu, 15 Feb 1996 10:06:04 GMT
- X-Mailer: Mozilla 1.1 (Windows; I; 16bit)
-
- (Sorry about the title, but nobody answered (or even read it!) under
- the boring title of "Help with Containers")
-
- Hi
-
- I want to modify a class which has been stored in a direct container.
- I'm not sure if this is only relative to Borland compilers as that is all
- I have used. A simplified section of code is shown below explaining what
- I am doing, and also what I want :-
-
- class TMyClass
- {
- overloaded == , = , < operators; (all work)
- TMyClass() {};
- copy constructor (works)
- //
- char Member[255];
- };
-
- typedef TArrayAsVector<TMyClass> ArrayOfMyClasses;
-
-
-
- int main(var1 , var2) //not sure what they are
- {
- ArrayOfMyClasses MyArray(5,0,5); //create array
- TMyClass c(); //instance of TMyClass
- MyArray.Add(c); //Add instance to container
- TMyClass d(); //Another instance
- MyArray.Add(d); //Add this instance to container.
-
- //using an ArrayIterator or ForEach, I can access the data no problem.
- // I want to access/change the data using [].
-
- strcpy((TMyClass&)MyArray[0].Member , "Some String"); //DOES NOT
- WORK!
-
- };
-
-
- The above code is not perfect by a long way but it should explain what I
- am trying to do. The contents of (TMyClass&)MyArray[0] are
- random/corrupt. Without the caster (TMyClass&) the compiler comes back
- with "Member is not a member of TArrayAsVector<TMyClass>"
-
- Any ideas?
-
- Thanks in advance
-
- >--Malc.
- >
- >The above questions are mine and not those of my employer.
- >
- >
- >
- >
- >
- >
-
-
-